###########################################################################
#
#  Copyright (C) 2007-2008 Florent AVELLANEDA (florent.avellaneda@gmail.com)
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser Public License for more details.
#  
#  You should have received a copy of the GNU Lesser Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################


EXT = cpp
CXX = g++
EXEC = exe

CXXFLAGS = -Wall -W 
LDFLAGS =  
MODE =

OBJDIR = obj
include .flag

SRC = $(wildcard *.$(EXT))
OBJ = $(SRC:.$(EXT)=.o)
OBJ := $(addprefix $(OBJDIR)/, $(OBJ))

.PHONY: debug release all

all: $(EXEC)

.flag:
	@touch .flag

debug:
	@echo -e "MODE = -DDEBUG -g\nOBJDIR = obj/Debug" > .flag

release:
	@echo -e "MODE = -DRELEASE\nOBJDIR = obj/Release" > .flag


$(EXEC): $(OBJ)
	@ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . /usr/include/boost/graph/
	@$(CXX) -o $@ $^ $(LDFLAGS)

$(OBJDIR)/%.o: %.$(EXT)
	@$(CXX) -o $@ -c $< $(CXXFLAGS) $(MODE) $(LDFLAGS)

clean:
	@rm -rf $(OBJDIR)/*.o $(OBJDIR)/*/*.o $(OBJDIR)/*/*/*.o
	@rm -f $(EXEC)

install: $(EXEC)
	@cp $(EXEC) /usr/bin/


